#ifndef __WAITERLIST_H__
#define __WAITERLIST_H__

#include "MyEvent.h"
#include "Lock.h"

#include <string>
#include <deque>
using namespace std;

typedef struct  tagRspInfo
{
	int			nLen;
	char		*pData;
	tagRspInfo()
	{
		pData = NULL;
		nLen = 0; 
	}
}RspInfo, *LPRspInfo;

class CWaiterList
{
	typedef string KeyType;
	typedef unsigned long ParamType;

	struct WaitItem
	{
		CMyEvent	myEvent;
		bool		isUsed;

		KeyType		strKey;
		ParamType	param;
	};

	typedef deque<WaitItem *> WaitList;

public:
	CWaiterList();
	~CWaiterList();

	int AddWaitItem(const KeyType &key);

	bool Wait(int nIndex, int nTimeout, ParamType &param);

	bool Signal(const KeyType &key, const ParamType &param);

private:
	WaitList	m_waitList;
	CLock		m_lockWaitList;
};
#endif
